from functools import cached_property
from webutils.layers.managers import JsonMixin
from webutils.layers.managers.redis import HashMixin, ListMixin

from .base import BaseManager


class Chatlist(JsonMixin, ListMixin, BaseManager):
    pass


class TextChat(Chatlist):
    @cached_property
    def list_key(self):
        return self.get_redis_key('chat', 'his', self.room_id)


class ImageChat(Chatlist):
    @cached_property
    def list_key(self):
        return self.get_redis_key('chat', 'img', 'his', self.room_id)


class GroupBlacklist(JsonMixin, HashMixin, BaseManager):
    @cached_property
    def hash_key(self):
        return self.get_redis_key('chat', 'blacklist', 'groups')


class UserBlacklist(JsonMixin, HashMixin, BaseManager):
    @cached_property
    def hash_key(self):
        return self.get_redis_key('chat', 'blacklist', 'members')
